<?php

	class Devmod_method_itemOperator extends Devmod_methods_abstraction {
		
		protected $after_operation = array(array(
										'for_method' => 'export', // in this method we want sth to handle | $devmod->>>EXPORT<<();
										'for_method_type' => 'list', // choose the type in this method | $devmod->type('>>LIST<<')->export();
										'use' => 'eval_export_list' // choose the local (in this class) method which will be executed
									));
		
		public function set_config($args)
		{
			$this->update_config('itemOperator', array($args[0] => $args[1]));
		}
		
		public function eval_export_list($args)
		{	
			if(!isset($this->config[$this->type]['itemOperator']) || count($args) == 0) return $args;
			
			foreach($args as $id => $row)
			{
				$row = $this->helper->object_to_array($row);
				
				foreach($row as $k => $v)
				{
					$new_obj[$id][$k] = $v;
				}
				
				foreach($this->config[$this->type]['itemOperator'] as $operator => $args)
				{
					$new_args = array();
					
					foreach($args as $key => $item)
					{
						$new_args[$key] = $this->helper->eval_vars($item, $row);
					}
					
					$new_obj[$id][$operator] = $this->helper->element_build("a", $new_args)->element_update($operator);
					
				}

			}
			return $this->helper->array_to_object($new_obj);
		}
		
	}